<?php
include_once (dirname(__FILE__) . "/../../includes/init.php");

global $db;

$action = $_POST['action'];

switch ($action) {
	case "edit_article":
		$article['article_id'] = intval($_POST['article_id']);
		$article['title'] = trim($_POST['title']);
		$article['content'] = trim($_POST['content']);
		$article['article_time'] = trim($_POST['article_time']);
		
		if ($article['article_id'] == 0) {
			$db->autoExecute("article", $article);
		} else {
			$db->autoExecute("article", $article, "UPDATE", " article_id = '{$article['article_id']}'");
		}
		header("location: list.php");
		break;
}